import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

/* Layout */
import Layout from '@/layout/index.vue'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/LoginView.vue'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/ErrorView.vue'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/DashboardView.vue'),
      meta: { title: 'Dashboard', icon: 'dashboard' }
    }, {
      path: 'home',
      name: 'Home',
      component: () => import('@/views/HomeView.vue'),
      meta: { title: 'Home', icon: 'home' }
    }, {
      path: 'about',
      name: 'About',
      component: () => import('@/views/AboutView.vue'),
      meta: { title: 'About', icon: 'about' }
    }]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]


const router = new VueRouter({
  mode: 'history',
  base: import.meta.env.BASE_URL,
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

export default router
